package com.qf.controller.doctorsController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.Doctors;
import com.qf.service.doctorsService.DoctorsService;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.qf.util.R;

import java.util.HashMap;
import java.util.List;

/**
 * (Doctors)表控制层
 *
 * @author makejava1
 * @since 2024-12-03 15:24:39
 */
@RestController
@RequestMapping("/api/doctors")
public class DoctorsController {
    /**
     * 服务对象
     */
    @Autowired
    private DoctorsService doctorsService;

    /**
     * 查全部
     *
     */
    @GetMapping("/list")
    public R list(Doctors doctors){

        PageHelper.startPage(doctors.getPageNum(),doctors.getPageSize());

        List<Doctors> list = doctorsService.list(doctors);

        PageInfo<Doctors> pageInfo = new PageInfo(list);

        return R.ok(pageInfo);
    }
    /**
     * 根据id查询
     */
    @GetMapping("/info")
    public R getById(@RequestParam("id") Integer id) {
        Doctors doctors = doctorsService.getById(id);
        return R.ok(doctors);
    }





    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody Doctors doctors) {
        boolean b = doctorsService.update(doctors);
        if (b) {
            return R.ok("修改成功");
        } else {
            return R.fail();
        }
    }

    /**
     * 更新审核状态
     */
    @PostMapping("/updateDoctorAudit")
    public R updateDoctorAudit(@RequestBody Doctors doctors){
        doctorsService.updateDoctorAudit(doctors);
        return R.ok();
    }


}
